package com.ufaud.ais.sys.entity;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

@Entity
@Table(name = "urlresource")
public class UrlResource {

	private Long urlId;
	private String url;

	@ManyToMany(fetch=FetchType.EAGER)
	@Fetch(value=FetchMode.JOIN)
	@JoinTable(name="urlresource_role_relation", joinColumns = @JoinColumn(name="url_id"), inverseJoinColumns = @JoinColumn(name="role_id"))
	private Set<Role> permittedRole = new HashSet<Role>();
	
	@Id
	@GeneratedValue
	@Column(name = "url_id")
	public Long getUrlId() {
		return urlId;
	}
	// @Column(name = "url")
	public String getUrl() {
		return url;
	}
	
	public void setUrlId(Long urlId) {
		this.urlId = urlId;
	}
	public void setUrl(String url) {
		this.url = url;
	}
	public Set<Role> getPermittedRole() {
		return permittedRole;
	}
	public void setPermittedRole(Set<Role> permittedRole) {
		this.permittedRole = permittedRole;
	}
	
}
